﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MemberPassword : OTS.MemberPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!TestLogin(HttpContext.Current))
            return;
        if (!Page.IsCallback)
        {
            OTS.Model.custom  model = GetCustom(HttpContext.Current);
            this.lblName.Text = model.cusLoginName;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strOldPwd = this.txtOldPwd.Text;
        string strNewPwd = this.txtNewPwd.Text;
        string strNewPwd1 = this.txtNewPwd1.Text;

        if (strOldPwd == "")
        {
            this.lblMsg.Text = "原密码不能为空！";
            return;
        }
        if (strNewPwd == "" || strNewPwd1 == "")
        {
            this.lblMsg.Text = "新密码不能为空！";
            return;
        }
        if (strNewPwd1 != strNewPwd)
        {
            this.lblMsg.Text = "两次输入的密码不一致";
            return;
        }
        OTS.BLL.CustomBLL bll = new OTS.BLL.CustomBLL();
        OTS.Model.custom  model = GetCustom(HttpContext.Current);
        if (bll.ChangePassword(model.cusID, strOldPwd, strNewPwd))
        {
            ClearSession(HttpContext.Current);
            OTS.Common.Jscript.AlertAndRedirect("密码更新成功！请重新登陆！", "login.aspx");
            Response.Redirect("login.aspx");
        }
        else
        {
            this.lblMsg.Text = "原密码输入错误！";
            this.txtOldPwd.Text = "";
        }
    }
}
